package com.project.thisDatabase.base.model.data;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

@Data
public class LimitItem {

    private Integer start;
    private Integer max;

    public LimitItem(Integer start, Integer max) {
        this.start = start;
        this.max = max;
    }

    public boolean isLimit() {
        return start != null || max != null;
    }

    @Override
    public String toString() {
        List<Integer> limits = new ArrayList<>();
        if (null != start) {
            limits.add(start);
        }

        if (null != max) {
            limits.add(max);
        }

        return StringUtils.join(limits, ",");
    }

}
